
import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.PrintStream;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Vinay
 */
public class Game
{
    /*Class to represent information of test subject*/
    public static class TestSubject
    {
        String firstName, lastName, occupation;
        int age;
    }

    /*Instantiation of the TestSubject class for storing profile information of the test taker*/
    public static TestSubject profileInfo = new TestSubject();

    /*flag to indicate whether the game board is free*/
    public static boolean free;

    /**Function to write an entry in the log file*/
    public void writeLog(String s)
    {
        try
        {
            FileOutputStream fout = new FileOutputStream("Log.txt", true);
            PrintStream p = new PrintStream(fout);

            p.println(s);
        }
        catch(Exception ex)
        {
            writeFile("err.txt", ex.getMessage());
                    
            System.out.print("Error Processing File " + ex);
        }
    }


    /*Function to read data from a file. Returns a BufferedReader for that file*/
    public BufferedReader readFile(String s)
    {
        FileReader fin = null;
        BufferedReader bin = null ;
        try
        {
            fin = new FileReader(s);
            bin = new BufferedReader(fin);
        }
        catch(Exception e)
        {
            writeFile("err.txt", e.getMessage());

            e.printStackTrace();
        }
        return bin;
    }

    /*Function to write an entry into the specified file*/
    public void writeFile(String fname, String s)
    {
        try
        {
            FileOutputStream fout = new FileOutputStream(fname, true);
            PrintStream p = new PrintStream(fout);

            p.println(s);
        }
        catch(Exception ex)
        {
            writeFile("err.txt", ex.getMessage());

            System.out.print("Error Processing File " + ex);
        }
    }

}
